function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()


  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}


//格式化正文body部分
function formatArticleBody(htmlString,myImgs){
  var div = window.document.createElement('div');
  div.innerHTML = htmlString;
  var elements = div.childNodes;

  var imgs = div.getElementsByTagName('img')
  var arrayLength = imgs.length;
  var imgArrayLen = myImgs.length;

  for (var i = 0; i < arrayLength; i++) {
    var item = myStringArray[i];
    //Do something
    item.removeAttribute("style");
    item.removeAttribute("width");
    item.className = 'article-img';
    item.src = '';
    for (var i = 0; i < imgArrayLen; i++) {
      var obj = myImgs[i];
      if (item.src == obj.Fname) {
        item.src = obj.OriginWithWaterMark;
      }
    }

  }

  console.log(div);

}

function mojotvEncoder(string){
    
    return string;
}



module.exports = {
  formatTime: formatTime,
  mojotvEncoder: mojotvEncoder,
  formatArticleBody: formatArticleBody
}